package demoFactoryproxy;

public class ProxyUser {
    private User realUser;

    public ProxyUser(User user){
        this.realUser = user;
    }

    public void menu(){
        this.realUser.menu();
    }

    public void borrowBook(String bookName){
        System.out.println("检查用户权限：");
        if(this.realUser instanceof NormalUser){
            ((NormalUser)this.realUser).borrowBook(bookName);
        }else {
            System.out.println("您没有权限借阅图书...");
        }
    }

    public void addBook(String bookName){
        System.out.println("检查用户权限：");
        if(this.realUser instanceof AdminUser){
            ((AdminUser)this.realUser).addBook(bookName);
        }else{
            System.out.println("您没有权限上架图书...");
        }
    }

}
